package com.tencent.ied.bk.filter.impl;

import com.tencent.ied.bk.common.Global;
import com.tencent.ied.bk.constant.CommonConstant;
import com.tencent.ied.bk.entity.BaseAbstractInfo;
import com.tencent.ied.bk.filter.AbstractFilter;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author chen_yu
 * @date 2021/3/11 2:56
 */
public class SizeFilter extends AbstractFilter {

    public SizeFilter(String name) {
        super(name);
    }

    @Override
    public boolean doFilter(BaseAbstractInfo filterObject) {
        int id = Global.ID_WORKER.getAndIncrement();
        if (id >= CommonConstant.ABSTRACT_NUM_LIMIT) {
            return false;
        }
        filterObject.setId(id);
        return true;
    }
}
